HAL LPTIM I/O functions migration

HAL LPTIM Input Capture (IC) Functions

Important

Differences in starting and stopping LPTIM input capture between HAL1 and HAL2

In HAL1, starting and stopping LPTIM Input Capture (IC) in polling, interrupt, or DMA modes is managed solely through the respective start and stop APIs for the channel:

  • HAL_LPTIM_IC_Start

  • HAL_LPTIM_IC_Start_IT

  • HAL_LPTIM_IC_Start_DMA

In HAL2, the process involves two levels of control — the channel and the LPTIM peripheral itself. Starting and stopping Input Capture requires:

  1. Starting or stopping the channel:

    • Start APIs: HAL_LPTIM_IC_StartChannel, HAL_LPTIM_IC_StartChannel_IT, HAL_LPTIM_IC_StartChannel_DMA

    • Stop APIs: HAL_LPTIM_IC_StopChannel, HAL_LPTIM_IC_StopChannel_IT, HAL_LPTIM_IC_StopChannel_DMA

  2. Starting or stopping the LPTIM peripheral:

    • Start APIs: HAL_LPTIM_Start, HAL_LPTIM_Start_IT, HAL_LPTIM_Start_DMA

    • Stop APIs: HAL_LPTIM_Stop, HAL_LPTIM_Stop_IT, HAL_LPTIM_Stop_DMA

Important ordering rules in HAL2:

  • The LPTIM Start operation (HAL_LPTIM_Start, _IT, _DMA) must be called only after all required channels have been started.

  • The LPTIM Stop operation (HAL_LPTIM_Stop, _IT, _DMA) must be called only after all required channels have been stopped.

This ensures proper synchronization between the peripheral and its channels, preventing potential issues during Input Capture operations. For more details, refer to Input Capture mode in other concepts

HAL1

HAL2

Input Capture Configuration

In HAL1, to configure the input channel, you need to call:

HAL_StatusTypeDef HAL_LPTIM_IC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                             const LPTIM_IC_ConfigTypeDef *sConfig,
                                             uint32_t Channel);

In HAL2, to configure the input channel, you need to call:

hal_status_t HAL_LPTIM_IC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                           hal_lptim_channel_t channel,
                                           const hal_lptim_ic_config_t *p_config);

Input Capture Start and Stop in polling mode

In HAL1, the input capture in polling mode is managed using the following functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_IC_Start(LPTIM_HandleTypeDef *hlptim,
                                         uint32_t Channel);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_IC_Stop(LPTIM_HandleTypeDef *hlptim,
                                        uint32_t Channel);
    

In HAL2, the polling mode is handled by:

  • To start:

    hal_status_t HAL_LPTIM_IC_StartChannel(hal_lptim_handle_t *hlptim,
                                           hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_IC_StopChannel(hal_lptim_handle_t *hlptim,
                                          hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

Input Capture Start and Stop in interrupt mode

In HAL1, the input capture in interrupt mode is managed using the following functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_IC_Start_IT(LPTIM_HandleTypeDef *hlptim,
                                            uint32_t Channel);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_IC_Stop_IT(LPTIM_HandleTypeDef *hlptim,
                                           uint32_t Channel);
    

In HAL2, the interrupt mode is handled by:

  • To start:

    hal_status_t HAL_LPTIM_IC_StartChannel_IT(hal_lptim_handle_t *hlptim,
                                              hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_IC_StopChannel_IT(hal_lptim_handle_t *hlptim,
                                             hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

Input Capture Start and Stop in DMA Mode

In HAL1, the input capture in DMA mode is managed using the following functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_IC_Start_DMA(LPTIM_HandleTypeDef *hlptim,
                                             uint32_t Channel,
                                             uint32_t *pData,
                                             uint32_t Length);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_IC_Stop_DMA(LPTIM_HandleTypeDef *hlptim,
                                            uint32_t Channel);
    

In HAL2, the DMA mode is handled by:

  • To start:

    hal_status_t HAL_LPTIM_IC_StartChannel_DMA(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const uint8_t *p_data,
                                               uint32_t size_byte);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_IC_StopChannel_DMA(hal_lptim_handle_t *hlptim,
                                              hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

Note

In HAL2, users are provided with additional asynchronous process APIs (with suffixes _DMA_Opt and _IT_Opt) that enable selective filtering of optional interrupts. Specifically, in the HAL2 LPTIM driver, this feature is applied to the DMA process through the following API, which allows users to choose the desired DMA interrupt option or to operate the DMA in silent mode—that is, without generating any interrupt.

hal_status_t HAL_LPTIM_IC_StartChannel_DMA_Opt(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const uint8_t *p_data,
                                               uint32_t size_byte,
                                               uint32_t interrupts);

Related concept: New APIs for filtering optional asynchronous process interrupts


HAL LPTIM Output Compare (OC) Functions:

Important

Differences in starting and stopping LPTIM in Output Compare (PWM, Set Once, One Pulse, timeout ) Between HAL1 and HAL2

In HAL1, starting and stopping LPTIM Output Compare (OC) in polling or interrupt modes is managed solely through the respective start and stop APIs for the channel:

  • HAL_LPTIM_PWM_Start, HAL_LPTIM_OnePulse_Start, HAL_LPTIM_SetOnce_Start, HAL_LPTIM_TimeOut_Start.

  • HAL_LPTIM_PWM_Start_IT, HAL_LPTIM_OnePulse_Start_IT, HAL_LPTIM_SetOnce_Start_IT, HAL_LPTIM_TimeOut_Start_IT.

  • HAL_LPTIM_PWM_Start_DMA

In HAL2, the process involves two levels of control — the channel and the LPTIM peripheral itself. Starting and stopping Output Compare requires:

  1. Starting or stopping the channel:

    • Start APIs: HAL_LPTIM_OC_StartChannel, HAL_LPTIM_OC_StartChannel_IT

    • Stop APIs: HAL_LPTIM_OC_StopChannel, HAL_LPTIM_OC_StopChannel_IT

  2. Starting or stopping the LPTIM peripheral:

    • Start APIs: HAL_LPTIM_Start, HAL_LPTIM_Start_IT

    • Stop APIs: HAL_LPTIM_Stop, HAL_LPTIM_Stop_IT

Important ordering rules in HAL2:

  • The LPTIM Start operation (HAL_LPTIM_Start, _IT, _DMA) must be called only after all required channels have been started.

  • The LPTIM Stop operation (HAL_LPTIM_Stop, _IT, _DMA) must be called only after all required channels have been stopped.

  • In HAL1, the API HAL_LPTIM_PWM_Start_DMA was provided to start the specified channel in output compare mode using DMA to update the CCR1 register (compare register). However, since the LPTIM peripheral does not support compare DMA requests, this function was not meaningful even in HAL1 and has been removed in HAL2. Users can still generate PWM signals using the polling and interrupt (IT) modes available in HAL2.

This ensures proper synchronization between the peripheral and its channels, preventing potential issues during Output Compare operations.

For more details, refer to LPTIM Counter output modes in other concepts

HAL LPTIM output compare configuration

HAL1

HAL2

HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                             const LPTIM_OC_ConfigTypeDef *sConfig,
                                             uint32_t Channel);
hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                           hal_lptim_channel_t channel,
                                           const hal_lptim_oc_config_t *p_config);

HAL LPTIM PWM functions

Important

  • In HAL1, there were a dedicated APIs specifically for PWM mode as shown in the following table.

  • In HAL2, The PWM specific APIs are removed. To generate a PWM output signal, user needs to call HAL_LPTIM_SetConfig() API by selecting the mode HAL_LPTIM_CONTINUOUS.

HAL1

HAL2

Polling mode

In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
    
    
    
    HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                                 const LPTIM_OC_ConfigTypeDef *sConfig,
                                                 uint32_t Channel);
    
    HAL_StatusTypeDef HAL_LPTIM_PWM_Start(LPTIM_HandleTypeDef *hlptim,
                                          uint32_t Channel);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_PWM_Stop(LPTIM_HandleTypeDef *hlptim,
                                         uint32_t Channel);
    

In HAL2, polling mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_Init(hal_lptim_handle_t *hlptim, hal_lptim_t instance);
    hal_status_t HAL_LPTIM_SetConfig(hal_lptim_handle_t *hlptim,
                                     const hal_lptim_config_t *p_config); /* p_config.mode = HAL_LPTIM_CONTINUOUS; */
    
    hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const hal_lptim_oc_config_t *p_config);
    
    hal_status_t HAL_LPTIM_OC_StartChannel(hal_lptim_handle_t *hlptim,
                                           hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_OC_StopChannel(hal_lptim_handle_t *hlptim,
                                          hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

Interrupt mode

In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
    
    
    
    HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                                 const LPTIM_OC_ConfigTypeDef *sConfig,
                                                 uint32_t Channel);
    
    HAL_StatusTypeDef HAL_LPTIM_PWM_Start_IT(LPTIM_HandleTypeDef *hlptim,
                                             uint32_t Channel);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_IT(LPTIM_HandleTypeDef *hlptim,
                                            uint32_t Channel);
    

In HAL2, the interrupt mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_Init(hal_lptim_handle_t *hlptim, hal_lptim_t instance);
    hal_status_t HAL_LPTIM_SetConfig(hal_lptim_handle_t *hlptim,
                                     const hal_lptim_config_t *p_config); /* p_config.mode = HAL_LPTIM_CONTINUOUS; */
    
    hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const hal_lptim_oc_config_t *p_config);
    
    hal_status_t HAL_LPTIM_OC_StartChannel_IT(hal_lptim_handle_t *hlptim,
                                              hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_OC_StopChannel_IT(hal_lptim_handle_t *hlptim,
                                             hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

DMA mode

In HAL1, the DMA mode for various timer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
    HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                                 const LPTIM_OC_ConfigTypeDef *sConfig,
                                                 uint32_t Channel);
    HAL_StatusTypeDef HAL_LPTIM_PWM_Start_DMA(LPTIM_HandleTypeDef *hlptim,
                                              uint32_t Channel,
                                              const uint32_t *pData,
                                              uint32_t Length);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_PWM_Stop_DMA(LPTIM_HandleTypeDef *hlptim,
                                             uint32_t Channel);
    

Important

In HAL1, the API HAL_LPTIM_PWM_Start_DMA() was provided to start the specified channel in output compare mode using DMA to update the CCR1 register (compare register). However, since the LPTIM peripheral does not support compare DMA requests, this function was not meaningful even in HAL1 and has been removed in HAL2. Users can still generate PWM signals using the polling and interrupt (IT) modes available in HAL2.

Related use case: PWM generator with external clock


HAL LPTIM one pulse start/stop functions

Important

  • In HAL1, there were a dedicated APIs specifically for one pulse mode as shown in the following table.

  • In HAL2, The one pulse mode specific APIs are removed. To generate a one pulse signal, user needs to call HAL_LPTIM_SetConfig() API by selecting the mode HAL_LPTIM_ONE_SHOT.

HAL1

HAL2

Polling mode

In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
    
    
    
    HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                                 const LPTIM_OC_ConfigTypeDef *sConfig,
                                                 uint32_t Channel);
    
    HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start(LPTIM_HandleTypeDef *hlptim,
                                               uint32_t Channel);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop(LPTIM_HandleTypeDef *hlptim,
                                              uint32_t Channel);
    

In HAL2, polling mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_Init(hal_lptim_handle_t *hlptim, hal_lptim_t instance);
    hal_status_t HAL_LPTIM_SetConfig(hal_lptim_handle_t *hlptim,
                                     const hal_lptim_config_t *p_config); /* p_config.mode = HAL_LPTIM_ONE_SHOT; */
    
    hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const hal_lptim_oc_config_t *p_config);
    
    hal_status_t HAL_LPTIM_OC_StartChannel(hal_lptim_handle_t *hlptim,
                                           hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_OC_StopChannel(hal_lptim_handle_t *hlptim,
                                          hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

Interrupt mode

In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
    
    
    
    HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                                 const LPTIM_OC_ConfigTypeDef *sConfig,
                                                 uint32_t Channel);
    
    HAL_StatusTypeDef HAL_LPTIM_OnePulse_Start_IT(LPTIM_HandleTypeDef *hlptim,
                                                  uint32_t Channel);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_OnePulse_Stop_IT(LPTIM_HandleTypeDef *hlptim,
                                                 uint32_t Channel);
    

In HAL2, the interrupt mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_Init(hal_lptim_handle_t *hlptim, hal_lptim_t instance);
    hal_status_t HAL_LPTIM_SetConfig(hal_lptim_handle_t *hlptim,
                                     const hal_lptim_config_t *p_config); /* p_config.mode = HAL_LPTIM_ONE_SHOT; */
    
    hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const hal_lptim_oc_config_t *p_config);
    
    hal_status_t HAL_LPTIM_OC_StartChannel_IT(hal_lptim_handle_t *hlptim,
                                           hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_OC_StopChannel_IT(hal_lptim_handle_t *hlptim,
                                          hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

HAL LPTIM set once start/stop functions

Important

  • In HAL1, there were a dedicated APIs specifically for set once mode as shown in the following table.

  • In HAL2, The set once specific APIs are removed. To generate a set once signal, user needs to call HAL_LPTIM_SetConfig() API by selecting the mode HAL_LPTIM_SET_ONCE.

HAL1

HAL2

Polling mode

In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
    
    
    
    HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                                 const LPTIM_OC_ConfigTypeDef *sConfig,
                                                 uint32_t Channel);
    
    HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start(LPTIM_HandleTypeDef *hlptim,
                                              uint32_t Channel);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop(LPTIM_HandleTypeDef *hlptim,
                                             uint32_t Channel);
    

In HAL2, polling mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_Init(hal_lptim_handle_t *hlptim, hal_lptim_t instance);
    hal_status_t HAL_LPTIM_SetConfig(hal_lptim_handle_t *hlptim,
                                     const hal_lptim_config_t *p_config); /* p_config.mode = HAL_LPTIM_SET_ONCE; */
    
    hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const hal_lptim_oc_config_t *p_config);
    
    hal_status_t HAL_LPTIM_OC_StartChannel(hal_lptim_handle_t *hlptim,
                                           hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_OC_StopChannel(hal_lptim_handle_t *hlptim,
                                          hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

Interrupt mode

In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
    
    
    
    HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                                 const LPTIM_OC_ConfigTypeDef *sConfig,
                                                 uint32_t Channel);
    
    HAL_StatusTypeDef HAL_LPTIM_SetOnce_Start_IT(LPTIM_HandleTypeDef *hlptim,
                                                 uint32_t Channel);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_SetOnce_Stop_IT(LPTIM_HandleTypeDef *hlptim,
                                                uint32_t Channel);
    

In HAL2, the interrupt mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_Init(hal_lptim_handle_t *hlptim, hal_lptim_t instance);
    hal_status_t HAL_LPTIM_SetConfig(hal_lptim_handle_t *hlptim,
                                     const hal_lptim_config_t *p_config); /* p_config.mode = HAL_LPTIM_SET_ONCE; */
    
    hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const hal_lptim_oc_config_t *p_config);
    
    hal_status_t HAL_LPTIM_OC_StartChannel_IT(hal_lptim_handle_t *hlptim,
                                              hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_OC_StopChannel_IT(hal_lptim_handle_t *hlptim,
                                          hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

HAL LPTIM timeout start/stop functions

Important

  • In HAL1, there were a dedicated APIs specifically for timeout mode as shown in the following table.

  • In HAL2, The timeout APIs are removed. To activate the timeout mode, user needs to call HAL_LPTIM_SetConfig() API by selecting the mode HAL_LPTIM_TIMEOUT.

HAL1

HAL2

Polling mode

In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
    
    
    
    HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                                 const LPTIM_OC_ConfigTypeDef *sConfig,
                                                 uint32_t Channel);
    
    HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start(LPTIM_HandleTypeDef *hlptim,
                                              uint32_t Timeout);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop(LPTIM_HandleTypeDef *hlptim);
    

In HAL2, polling mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_Init(hal_lptim_handle_t *hlptim, hal_lptim_t instance);
    hal_status_t HAL_LPTIM_SetConfig(hal_lptim_handle_t *hlptim,
                                     const hal_lptim_config_t *p_config); /* p_config.mode = HAL_LPTIM_TIMEOUT; */
    
    hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const hal_lptim_oc_config_t *p_config);
    
    hal_status_t HAL_LPTIM_OC_StartChannel(hal_lptim_handle_t *hlptim,
                                           hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_OC_StopChannel(hal_lptim_handle_t *hlptim,
                                          hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

Interrupt mode

In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Init(LPTIM_HandleTypeDef *hlptim);
    
    
    
    HAL_StatusTypeDef HAL_LPTIM_OC_ConfigChannel(LPTIM_HandleTypeDef *hlptim,
                                                 const LPTIM_OC_ConfigTypeDef *sConfig,
                                                 uint32_t Channel);
    
    HAL_StatusTypeDef HAL_LPTIM_TimeOut_Start_IT(LPTIM_HandleTypeDef *hlptim,
                                                 uint32_t Timeout);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_TimeOut_Stop_IT(LPTIM_HandleTypeDef *hlptim);
    

In HAL2, the interrupt mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_Init(hal_lptim_handle_t *hlptim, hal_lptim_t instance);
    hal_status_t HAL_LPTIM_SetConfig(hal_lptim_handle_t *hlptim,
                                     const hal_lptim_config_t *p_config); /* p_config.mode = HAL_LPTIM_TIMEOUT; */
    
    hal_status_t HAL_LPTIM_OC_SetConfigChannel(hal_lptim_handle_t *hlptim,
                                               hal_lptim_channel_t channel,
                                               const hal_lptim_oc_config_t *p_config);
    
    hal_status_t HAL_LPTIM_OC_StartChannel_IT(hal_lptim_handle_t *hlptim,
                                              hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_OC_StopChannel_IT(hal_lptim_handle_t *hlptim,
                                          hal_lptim_channel_t channel);
    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

HAL LPTIM encoder functions

Refer to Other concepts

HAL1

HAL2

Polling mode

In HAL1, the polling mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Encoder_Start(LPTIM_HandleTypeDef *hlptim);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop(LPTIM_HandleTypeDef *hlptim);
    

In HAL2, polling mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_SetConfigEncoder(const hal_lptim_handle_t *hlptim,
                                            const hal_lptim_encoder_config_t *p_encoder);
    hal_status_t HAL_LPTIM_Start(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_Stop(hal_lptim_handle_t *hlptim);
    

Interrupt mode

In HAL1, the interrupt mode for various lptimer functionalities is managed using specific functions:

  • To start:

    HAL_StatusTypeDef HAL_LPTIM_Encoder_Start_IT(LPTIM_HandleTypeDef *hlptim);
    
  • To stop:

    HAL_StatusTypeDef HAL_LPTIM_Encoder_Stop_IT(LPTIM_HandleTypeDef *hlptim);
    

In HAL2, the interrupt mode is handled by the following sequence:

  • To start:

    hal_status_t HAL_LPTIM_SetConfigEncoder(const hal_lptim_handle_t *hlptim,
                                            const hal_lptim_encoder_config_t *p_encoder);
    hal_status_t HAL_LPTIM_Start_IT(hal_lptim_handle_t *hlptim);
    
  • To stop:

    hal_status_t HAL_LPTIM_Stop_IT(hal_lptim_handle_t *hlptim);
    

Related use case: encoder mode